﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DNNspot.LiveChat.DataModel
{
    public class AgentInfo
    {
        private readonly User _user = new User();

        public int? AgentId { get; set; }
        public bool? IsLoggedIn { get; set; }
        public int? PortalId { get; set; }
        public int? UserId { get; set; }

        public string DisplayName
        {
            get { return _user.DisplayName; }
        }

        public string FullName
        {
            get { return string.Format("{0} {1}", _user.FirstName, _user.LastName); }
        }

        public string ShortName
        {
            get { return string.Format("{0} {1}",_user.FirstName, _user.LastName.Substring(0, 1)); }
        }

        public AgentInfo()
        {
        }

        public AgentInfo(Agent agent)
        {
            AgentId = agent.AgentId;
            IsLoggedIn = agent.IsLoggedIn;
            PortalId = agent.PortalId;
            UserId = agent.UserId;

            if(agent.UserId != null)
                _user.LoadByPrimaryKey(Convert.ToInt32(agent.UserId));
        }
    }
}
